package com.hubu.mapper;
import com.hubu.pojo.*;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface studentUserMapper {
    @Select("SELECT 学生账号 AS username, 学生密码 AS password " +
            "FROM 学生账号表 " +
            "WHERE 学生账号 = #{username} AND 学生密码 = #{password}")
    studentUser select(@Param("username") String username, @Param("password") String password);
    @Select("select 学号 AS id,姓名 AS name,性别 AS gender,年龄 AS age,已修学分 AS credit,班级号 AS class_id from 学生表 where 学号=#{id}")
    student_Information selectStudentById(String id);
    //根据用户名和密码查询用户对象

    @Update("UPDATE 学生账号表 SET 学生密码 = #{newPassword} WHERE 学生账号 = #{username}")
    void updatePassword(@Param("username") String username, @Param("newPassword") String newPassword);


    @Select("SELECT 课程号 AS course_id, 学期 AS term, 成绩 AS grade , 教师号 AS teacher_id, 学分 AS credits" +
            "    FROM 成绩报告表 WHERE 学号 = #{student_id} AND 成绩 != 0.0 ")
    List<grade_Information> selectAllgrade(@Param("student_id")String student_id);

   /* @Select("SELECT 课程号 AS course_id, 学期 AS term, 成绩 AS grade, 教师号 AS teacher_id, 学分 AS credits" +
            " FROM 成绩报告表 WHERE 学号 = #{studentId} AND 成绩 IS NOT NULL")
    List<GradeInformation> selectAllGrade(@Param("studentId") String studentId);*/

    @Select("SELECT 学号 AS id ,姓名 AS name ,性别 AS gender,班级号 class_id,年龄 AS age  FROM 学生表 WHERE 学号=#{id}")
    student_Information selectStudent(String id);

    @Select("SELECT 课程号 AS course_id, 课程名称 AS course_name, 学时 AS hour, 教师号 AS  teacher_id, 考核方式 AS method, 学分 AS credits  FROM 课程表 ")
    List<course_Information> selectAllCourse();

    @Insert("insert into 成绩报告表 values (#{id},#{course_id},#{term},#{grade},#{teacher_id},#{credits})")
    void inChooseCourse(grade_Information gradeInformation);


    @Select("SELECT 课程号 AS course_id  from 成绩报告表 where 课程号=#{course_id} and 学号=#{id}")
    // Mapper 接口中使用@Param注解
    grade_Information selectByCourse(@Param("course_id") String course_id, @Param("id") String id);

}